// 优惠券管理1
"use strict";
const { Controller } = require("egg");

class cCoupons extends Controller {
  // 查询所有优惠券
  async pc_c_query() {
    const { ctx } = this;
    const result = await ctx.service.sCoupons.pc_s_query(ctx?.query ?? {});
    ctx.body = result;
  }

  // 查询用户拥有的优惠券
  async wa_c_query_ucoupons() {
    const { ctx } = this;
    const result = await ctx.service.sCoupons.wa_s_query_ucoupons(ctx?.query ?? {});
    ctx.body = result;
  }
 
 // 用户领取优惠券
 async wa_c_create_usercoupons() {
  console.log("?? - pc_c_create");
  const { ctx } = this;
  const result = await ctx.service.sCoupons.wa_s_create_usercoupons(
    ctx?.request?.body ?? {}
  );
  ctx.body = result;
}

  // 修改用户拥有的优惠券的状态
  async wa_c_update_usercoupons() {
    console.log("?? - wa_c_update_usercoupons");
    const { ctx } = this;
    const result = await ctx.service.sCoupons.wa_s_update_usercoupons(
      ctx?.request?.body ?? {}
    );
    ctx.body = result;
  }
  // 增加优惠券
  async pc_c_create() {
    console.log("?? - pc_c_create");
    const { ctx } = this;
    const result = await ctx.service.sCoupons.pc_s_create(
      ctx?.request?.body ?? {}
    );
    ctx.body = result;
  }

  // 修改优惠券
  async pc_c_update() {
    console.log("?? - pc_c_update");
    const { ctx } = this;
    const result = await ctx.service.sCoupons.pc_s_update(
      ctx?.request?.body ?? {}
    );
    ctx.body = result;
  }

  // 删除优惠券
  async pc_c_delete() {
    console.log("?? - pc_c_delete");
    const { ctx } = this;
    const result = await ctx.service.sCoupons.pc_s_delete(ctx?.query ?? {});
    ctx.body = result;
  }
}

module.exports = cCoupons;
